package LC1456;

public class Solution {
	public static int maxVowels(String s, int k) {
		int cnt = 0;
		int temp = 0;
		for(int i = 0; i <= k - 2; i++) {
			char ch = s.charAt(i);
			if(isY(ch))cnt++;
		}
		int left = 0;
		int right = k - 1;
		while((++right) != s.length()) {
			char ch0 = s.charAt(left);
			char ch1 = s.charAt(right);
			if(isY(ch1)) {
				cnt++;
				if(cnt == k) {
					return cnt;
				}
			}
			if(cnt > temp) {
					temp = cnt;
				}
			if(isY(ch0)) {
				cnt--;
			}
			left++;
		}
        return temp;
    }
	
	public static boolean isY(char ch) {
		if(ch == 'a' || ch == 'e' || ch == 'i' || ch == 'o' || ch == 'u') return true;
		return false;
	}
}
